$(document).ready(function () {
	$(window).mouseover(function(){
			
	if($(".set_readonly input").length)
	{
		$(".set_readonly input").attr("readonly","readonly");
	}
/*	
	if($(".project_area_pic_src input").length)
		{
			area_code = $(".project_code input").val() || "*#*none_area_code*#*";
		
			if (!$(".project_code").length)
			{
				$(".project_area_code input").attr("readonly","readonly");
				$(".project_area_plot_pic_src input").attr("readonly","readonly");
			}
			else
			{
				$(".project_area_pic_src input").val(area_code);
			}			
		}
*/		
	});
	
	
	$('body').append("<div id='plot_address_backup' style='display:none;'>\
	<input id='project_plot_address_backup'></input><div>");
	
	$(".project_plot_address input").live('click',function(){
		$('#project_plot_address_backup').val($(".project_plot_address input").val());
	});	
	
	$(".project_plot_address input").live('mouseleave',function(){
		if ($('#project_plot_address_backup') != $(".project_plot_address input").val())
		{	
			geocoder = new qq.maps.Geocoder({
        complete : function(result){
            	$('.project_plot_address_map input').val(result.detail.location.toString());           
						}
			});		
		
			geocoder.getLocation($('.project_plot_address input').val());
		}
	});


	$('body').append("<div id='view_2D_set_background'></div>");
	$("#view_2D_set_background").click(function(event){			
		$("#view_2D_set").remove();
		$("#view_2D_set_background").hide();	
	});
	
	
	$(".project_area_plot_address_map input").live('click',function(event){
		
		if ($(this).attr("readonly") =="readonly")
		{
			return;
		}
		
		$('body').append("<div id='view_2D_set'></div>");		
		$("#view_2D_set_background").show();
		
		$('#view_2D_set').append("<div style='height:20px;text-align:left;color:rgba(124,123,173,1);margin-bottom:3%;'>分区设定：</div>");
		$('#view_2D_set').append("<div id='view_2D_set_body' style='width:100%;height:90%;'></div>");
				
		var myLatlng = new qq.maps.LatLng($('.project_plot_address_map input').val().split(',')[0],$('.project_plot_address_map input').val().split(',')[1]);
  	var myOptions = {
    	zoom: 17,
    	center: myLatlng,
   		mapTypeId: qq.maps.MapTypeId.ROADMAP
 		}
  	var map = new qq.maps.Map(document.getElementById("view_2D_set_body"), myOptions);
  
  	qq.maps.event.addListener(map,'click',function(event) {
      var latLng = event.latLng,
      lat = latLng.getLat().toFixed(5),
      lng = latLng.getLng().toFixed(5);
      $('.project_area_plot_address_map input').val(lat+','+lng);
      $("#view_2D_set").remove();
			$("#view_2D_set_background").hide();
    });

	});
	
	
	
});

